import 'dart:convert';

import 'package:safetymonitor/app/data/common/choice_bean.dart';
import 'package:safetymonitor/generated/json/base/json_field.dart';
import 'package:safetymonitor/generated/json/corporation_name_entity.g.dart';

export 'package:safetymonitor/generated/json/corporation_name_entity.g.dart';

@JsonSerializable()
class CorporationNameEntity implements ChoiceBean {

	CorporationNameEntity({
		this.name,
     this.parentId,
     this.sort,
     this.leaderUserId,
     this.phone,
     this.email,
     this.status,
     this.createTime,
     this.flag,
    this.id,
    this.isChecked = false,
	});

	factory CorporationNameEntity.fromJson(Map<String, dynamic> json) => $CorporationNameEntityFromJson(json);
	// 部门编号
	int? id = 0;
	// 部门名称
	String? name = '';
	// 父部门id
	int? parentId;
	// 排序
	int? sort;
	// 负责人的用户编号
	int? leaderUserId;
	// 联系电话
	String? phone = '';
	String? email = '';
	// 状态,见 CommonStatusEnum 枚举
	int? status;
	int? createTime = 0;
	// 公司或部门标识,1-部门，2-公司
	int? flag = 1;

	/// 是否选中
	bool isChecked = false;

	Map<String, dynamic> toJson() => $CorporationNameEntityToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}

  @override
  String getId() {
		return id.toString();
  }

  @override
  String getShowName() {
		return name ?? '';
  }

	@override
	bool getIsChecked() {
		return isChecked;
	}

	@override
	setIsChecked(bool isChecked) {
		this.isChecked = isChecked;
	}

}